home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / demostuf / plasma2.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1994-07-25  |  2.6 KB  |  191 lines

  1. program plasma2;
  2. {
  3.     Plasma dude #2
  4.     - by Bjarke Viksφe
  5.     feb 1994
  6.  
  7.   THIS PROGRAM WAS CODED BY BJARKE VIKS0E.
  8.   YOU ARE FREE TO DO WHATEVER YOU WANT WITH THIS PIECE OF CODE.
  9.   E-MAIL ME AT: dat92230@rix02.lyngbyes.dk IN 1994 FOR CHAT AND CODE.
  10.  
  11.     Too easy. Who can't do plasma these days. Pretty fast, though.
  12.     No cycling colours this time, eh?
  13. }
  14.  
  15. uses
  16.     DEMOINIT;
  17.  
  18. const
  19.     DEBUG = FALSE;
  20.  
  21. var
  22.     o1,o2,p1,p2 : byte;
  23.     q1,q2 : byte;
  24.     sinustabel  : array[0..255] of byte;
  25.  
  26. const
  27.     display1 : integer = $0000;
  28.     display2 : integer = $4000;
  29.  
  30.  
  31. (*------------------------------------------------*)
  32.  
  33. procedure SwapDisplay;
  34. begin
  35.     asm
  36.         mov    ax,display1
  37.         mov    dx,display2
  38.         mov    display1,dx
  39.         mov    display2,ax
  40.     end;
  41.     SetAddress(Ptr(SEGA000,display2));
  42. end;
  43.  
  44.  
  45. (*------------------------------------------------*)
  46.  
  47. procedure SetupSinus;
  48. var
  49.     i : integer;
  50.     v, vadd : real;
  51. begin
  52.     v:=0.0;
  53.     vadd:=(2.0*pi/256.0);
  54.     for i:=0 to 255 do
  55.     begin
  56.         sinustabel[i]:=round(sin(v)*63)+64;
  57.         v:=v+vadd;
  58.     end;
  59. end;
  60.  
  61. procedure SetColors;
  62. var
  63.     i : integer;
  64.     r,g,b : byte;
  65. begin
  66.     r:=0; b:=0; g:=0;
  67.     for i:=0 to 63 do begin
  68.         setRGB(i,r,g,b);
  69.         inc(r);
  70.     end;
  71.     for i:=64 to 127 do begin
  72.         dec(r);
  73.         setRGB(i,r,g,b);
  74.     end;
  75.     for i:=128 to 191 do begin
  76.         setRGB(i,r,g,b);
  77.         inc(r);
  78.         inc(g);
  79.     end;
  80.     for i:=192 to 255 do begin
  81.         dec(r);
  82.         dec(g);
  83.         setRGB(i,r,g,b);
  84.     end;
  85. end;
  86.  
  87.  
  88. procedure SetupDemo;
  89. var
  90.     i : integer;
  91. begin
  92.     ClearWholeScreen;
  93.     SetupSinus;
  94.     SetColors;
  95.  
  96.     o1:=54; o2:=64;
  97.     p1:=87; p2:=230;
  98. end;
  99.  
  100.  
  101. (*------------------------------------------------*)
  102.  
  103. procedure PlasmaLife; assembler;
  104. var
  105.     temp : byte;
  106.     ypos : integer;
  107. asm
  108.     mov    al,p1
  109.     mov    q1,al
  110.     mov    al,p2
  111.     mov    q2,al
  112.  
  113.     mov    es,SEGA000
  114.     mov    di,display1
  115.     lea    bx,sinustabel
  116.     xor    ax,ax
  117.     mov    dl,o1
  118.     mov    dh,o2
  119.     mov    ypos,100
  120.     cld
  121. @yloop:
  122.     mov    al,q1
  123.     xlat
  124.     mov    dl,al
  125.     mov    al,q2
  126.     xlat
  127.     mov    dh,al
  128.  
  129.     push    dx
  130.     mov    cx,80/2
  131. @xloop:
  132.     mov    al,dl
  133.     xlat
  134.     mov    ah,al
  135.     mov    al,dh
  136.     xlat
  137.     add    al,ah
  138.     mov    temp,al
  139.     inc    dl
  140.     dec    dh
  141.  
  142.     mov    al,dl
  143.     xlat
  144.     mov    ah,al
  145.     mov    al,dh
  146.     xlat
  147.     add    ah,al
  148.     mov    al,temp
  149.     inc    dl
  150.  
  151.     stosw
  152.     dec    cx
  153.     jnz    @xloop
  154.     pop    dx
  155.     sub    q1,2
  156.     add    q2,1
  157.     dec    ypos
  158.     jnz    @yloop
  159. end;
  160.  
  161. procedure ChangeAngle;
  162. begin
  163.     dec(o1,2);
  164.     inc(o2,1);
  165.     inc(p1,1);
  166.     dec(p2,2);
  167. end;
  168.  
  169.  
  170. (*------------------------------------------------*)
  171.  
  172. procedure RunOnce;
  173. begin
  174.     SwapDisplay;
  175.     VBLANK;
  176.     if DEBUG then setrgb(0,63,0,0);
  177.     SetBitplanes(15);
  178.     PlasmaLife;
  179.     ChangeAngle;
  180.     if DEBUG then setrgb(0,0,0,0);
  181. end;
  182.  
  183.  
  184. begin
  185.     OpenScreen;
  186.     SetLineRepeat(3);
  187.     SetupDemo;
  188.     while (not KeyPressed) do RunOnce;
  189.     CloseScreen;
  190. end.
  191.